/*     */ package com.feeyin.radar.sys.controller;
/*     */ 
/*     */ import com.feeyin.radar.sys.model.FunctionTree;
/*     */ import com.feeyin.radar.sys.service.FunctionTreeService;
/*     */ import com.feeyin.radar.sys.service.OperateService;
/*     */ import java.util.ArrayList;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.springframework.web.servlet.ModelAndView;
/*     */ import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
/*     */ import org.springframework.web.servlet.view.RedirectView;
/*     */ 
/*     */ public class FunctionTreeController extends MultiActionController
/*     */ {
/*     */   private FunctionTreeService functionTreeService;
/*     */   private OperateService operateService;
/*     */   private String functionManage;
/*     */   private String addFunction;
/*     */   private String updateFunction;
/*     */   private String viewFunction;
/*     */ 
/*     */   public FunctionTreeService getFunctionTreeService()
/*     */   {
/*  35 */     return this.functionTreeService;
/*     */   }
/*     */ 
/*     */   public void setFunctionTreeService(FunctionTreeService functionTreeService) {
/*  39 */     this.functionTreeService = functionTreeService;
/*     */   }
/*     */ 
/*     */   public OperateService getOperateService() {
/*  43 */     return this.operateService;
/*     */   }
/*     */ 
/*     */   public void setOperateService(OperateService operateService) {
/*  47 */     this.operateService = operateService;
/*     */   }
/*     */ 
/*     */   public String getFunctionManage() {
/*  51 */     return this.functionManage;
/*     */   }
/*     */ 
/*     */   public void setFunctionManage(String functionManage) {
/*  55 */     this.functionManage = functionManage;
/*     */   }
/*     */ 
/*     */   public String getAddFunction() {
/*  59 */     return this.addFunction;
/*     */   }
/*     */ 
/*     */   public void setAddFunction(String addFunction) {
/*  63 */     this.addFunction = addFunction;
/*     */   }
/*     */ 
/*     */   public String getUpdateFunction() {
/*  67 */     return this.updateFunction;
/*     */   }
/*     */ 
/*     */   public void setUpdateFunction(String updateFunction) {
/*  71 */     this.updateFunction = updateFunction;
/*     */   }
/*     */ 
/*     */   public String getViewFunction() {
/*  75 */     return this.viewFunction;
/*     */   }
/*     */ 
/*     */   public void setViewFunction(String viewFunction) {
/*  79 */     this.viewFunction = viewFunction;
/*     */   }
/*     */ 
/*     */   public ModelAndView display(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*  85 */     request.setAttribute("result", request.getParameter("result"));
/*     */ 
/*  87 */     List functions = new ArrayList();
/*  88 */     functions = this.functionTreeService.getFunctions();
/*  89 */     return new ModelAndView(getFunctionManage(), "functions", functions);
/*     */   }
/*     */ 
/*     */   public ModelAndView viewFunction(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 105 */     Map map = new HashMap();
/*     */ 
/* 107 */     String id = request.getParameter("id");
/* 108 */     FunctionTree function = new FunctionTree();
/* 109 */     if ((id != null) && (!"".equals(id))) {
/* 110 */       function = this.functionTreeService.getFunction(Integer.valueOf(Integer.parseInt(id)));
/*     */ 
/* 112 */       List operates = new ArrayList();
/* 113 */       operates = this.operateService.getOperatesByFunctionId(Integer.valueOf(Integer.parseInt(id)));
/* 114 */       map.put("operates", operates);
/*     */     }
/* 116 */     map.put("function", function);
/*     */ 
/* 119 */     return new ModelAndView(getViewFunction(), map);
/*     */   }
/*     */ 
/*     */   public ModelAndView preAddFunction(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 124 */     request.setAttribute("result", request.getParameter("result"));
/* 125 */     request.setAttribute("repeat", request.getAttribute("repeat"));
/*     */ 
/* 128 */     List functions = new ArrayList();
/* 129 */     functions = this.functionTreeService.getFunctionsByActivity();
/* 130 */     return new ModelAndView(getAddFunction(), "functions", functions);
/*     */   }
/*     */ 
/*     */   public ModelAndView addFunction(HttpServletRequest request, HttpServletResponse response, FunctionTree functionTree)
/*     */   {
/* 135 */     boolean result = false;
/* 136 */     int success = 0;
/*     */ 
/* 138 */     if (functionTree != null) {
/* 139 */       FunctionTree func = new FunctionTree();
/* 140 */       func = this.functionTreeService.getFunctionByNameParentId(functionTree.getFunctionName(), functionTree.getParentId());
/* 141 */       if (func != null) {
/* 142 */         request.setAttribute("repeat", Integer.valueOf(1));
/* 143 */         request.setAttribute("function", functionTree);
/* 144 */         return preAddFunction(request, response);
/*     */       }
/* 146 */       result = this.functionTreeService.insertFunction(functionTree);
/*     */     }
/* 148 */     if (result) success = 1;
/*     */ 
/* 150 */     return new ModelAndView(new RedirectView("./functionTree.do?action=preAddFunction&result=" + success));
/*     */   }
/*     */ 
/*     */   public ModelAndView preUpdateFunction(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 155 */     request.setAttribute("result", request.getParameter("result"));
/* 156 */     request.setAttribute("repeat", request.getAttribute("repeat"));
/*     */ 
/* 158 */     List functions = new ArrayList();
/* 159 */     functions = this.functionTreeService.getFunctionsByActivity();
/* 160 */     request.setAttribute("functions", functions);
/*     */ 
/* 162 */     String id = request.getParameter("id");
/* 163 */     FunctionTree function = new FunctionTree();
/* 164 */     if ((id != null) && (!"".equals(id))) {
/* 165 */       function = this.functionTreeService.getFunction(Integer.valueOf(Integer.parseInt(id)));
/*     */     }
/* 167 */     request.setAttribute("function", function);
/*     */ 
/* 169 */     return new ModelAndView(getUpdateFunction());
/*     */   }
/*     */ 
/*     */   public ModelAndView updateFunction(HttpServletRequest request, HttpServletResponse response, FunctionTree functionTree)
/*     */   {
/* 174 */     boolean result = false;
/* 175 */     int success = 0;
/*     */ 
/* 177 */     if (functionTree != null) {
/* 178 */       if (this.functionTreeService.isRepeatUpdateFunction(functionTree)) {
/* 179 */         request.setAttribute("repeat", Integer.valueOf(1));
/* 180 */         request.setAttribute("function", functionTree);
/* 181 */         return preUpdateFunction(request, response);
/*     */       }
/* 183 */       result = this.functionTreeService.updateFunction(functionTree);
/*     */     }
/* 185 */     if (result) success = 1;
/*     */ 
/* 187 */     return new ModelAndView(new RedirectView("./functionTree.do?action=preUpdateFunction&id=" + functionTree.getId() + "&result=" + success));
/*     */   }
/*     */ 
/*     */   public ModelAndView deleteFunction(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 192 */     boolean result = false;
/* 193 */     int success = 0;
/*     */ 
/* 195 */     String id = request.getParameter("id");
/* 196 */     String parentId = request.getParameter("parentId");
/* 197 */     FunctionTree function = new FunctionTree();
/* 198 */     if ((id != null) && (!"".equals(id)) && 
/* 199 */       (parentId != null) && (!"".equals(parentId))) {
/* 200 */       result = this.functionTreeService.deleteFunction(Integer.valueOf(Integer.parseInt(id)), Integer.valueOf(Integer.parseInt(parentId)));
/*     */     }
/* 202 */     if (result) success = 1;
/*     */ 
/* 204 */     return new ModelAndView(new RedirectView("./functionTree.do?action=display&result=" + success));
/*     */   }
/*     */ }

/* Location:           C:\Users\e547415\MyProject\rone\WEB-INF\classes\
 * Qualified Name:     com.feeyin.radar.sys.controller.FunctionTreeController
 * JD-Core Version:    0.6.0
 */